<% layout('layout/layout') %>
<% block('header').append(`<style>
</style>`)%>
<div id="goods_wrap" class="row">
  <div class="col-xs-12">
    <div class="box">
      <div class="box-header">
        <h3 class="box-title"><%=title %></h3>
        <div class="box-tools">
          <a class="btn  btn-sm btn-success" href="add">添加+</a>
          <!--<div class="input-group input-group-sm" style="width: 150px;">-->
          <!--<input type="text" name="table_search" class="form-control pull-right" placeholder="Search">-->

          <!--<div class="input-group-btn">-->
          <!--<button type="submit" class="btn btn-default"><i class="fa fa-search"></i></button>-->
          <!--</div>-->
          <!--</div>-->
        </div>
      </div>
      <!-- /.box-header -->
      <div class="box-body table-responsive no-padding">
        <table class="table table-bordered table-hover">
          <tbody>
          <tr>
            <th>名称</th>
            <th>图片预览</th>
            <th>商品类型</th>
            <th>上架状态</th>
            <th>访问次数</th>
            <th>卖出数量</th>
            <th>创建时间</th>
            <th>操作</th>
          </tr>
          <% goods.forEach(function(item){%>
          <tr>
            <td><%=item.name %></td>
            <td>
              <%if (item.imgTmb) {%>
                  <img src="<%=item.imgTmb %>" style="max-width:150px;max-height:100px;" >
                <% } else {%><span>无</span><% }%>
            <td>
              <% if (item.isHot ===1) { %>
              推荐商品
              <% } else if (item.isHot ===2) {  %>
              热卖商品
              <% } else if (item.isHot ===3) {  %>
              新品上市
              <% } else { %>
              普通商品
              <% }%>
            </td>
            <td>
              <%= item.onSale? '上架':'下架' %>
            </td>
            <td>
              <%= item.viewCount %>
            </td>
            <td>
              <%=item.sellCount %>
            </td>
            <td><%=item.create_at_ago()%></td>
            <td>
              <a class="btn  btn-sm btn-success" href="add?update=<%=item._id %>">修改</a>
              <a class="btn btn-delete  btn-sm btn-danger" data-id="<%=item._id%>" data-url="<%=assetsPath %>/goods/delete" href="javascript:void(0)">删除</a>
            </td>
          </tr>
          <% }) %>
          </tbody>
        </table>
      </div>
      <!-- /.box-body -->
    </div>
    <!-- /.box -->
    <div class="j_pager" data-page="<%=page %>"  data-count="<%=count%>"></div>
  </div>

</div>
<% block('footer').append(`<script src="${assetsPath}/js/uploadImg.js"></script>`); %>
<% block('footer').append(`<script src="${assetsPath}/js/pager.js" ></script>`); %>
<% block('footer').append(`<script>
jQuery(function() {
    $('.j_pager').pager()
    $.delBtn('#goods_wrap','你确定要删掉这个商品')
})
</script>`)%>